package com.liuguang.gateway.controller;

import com.liuguang.api.article.ArticleService;
import com.liuguang.api.article.dto.ArticleDTO;
import com.liuguang.common.pojo.CommonResult;
import com.liuguang.gateway.config.security.others.CurrentUserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @ClassName: ArticleController
 * @Description：文章相关的接口
 * @Author: wanghr
 * Date: 3:06 PM 2020/10/17
 * Version: 1.0
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    private static final Logger logger = LoggerFactory.getLogger(ArticleController.class);

//    @DubboReference(timeout = 40000)
    private ArticleService articleService;

    /**
     * 发布文章接口
     *
     * @params: []
     */
    @RequestMapping("/publish")
    public CommonResult<?> publishArticle(HttpServletRequest request,@Valid ArticleDTO articleDto) {

//        logger.info("ArticleController获取userinfo：{}",CurrentUserHolder.getCurrentUser());
        return articleService.publish(articleDto);
    }
}
